package com.sdy.healthcode.biz.service.impl;

import com.sdy.healthcode.biz.dto.ReportPost;
import com.sdy.healthcode.biz.model.Report;
import com.sdy.healthcode.biz.mapper.ReportMapper;
import com.sdy.healthcode.biz.service.ReportService;
import com.sdy.mvc.service.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zzq
 * @since 2020-02-19
 */
@Slf4j
@Service
public class ReportServiceImpl extends BaseServiceImpl<Report> implements ReportService {
    @Autowired
    private ReportMapper reportMapper;

    @Override
    public void report(ReportPost reportPost) {
        Report report = new Report()
                .setUserId(reportPost.getUserId())
                .setTitle(reportPost.getTitle())
                .setContent(reportPost.getContent())
                .setImgs(String.join(";", reportPost.getImgs()))
                .setState(1)
                .setCreateTime(new Date());
        save(report);
    }
}
